<html>
<head><meta charset="utf-8"><title>properly render HRTBs · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/properly.20render.20HRTBs.html">properly render HRTBs</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236978558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/properly%20render%20HRTBs/near/236978558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/properly.20render.20HRTBs.html#236978558">(May 01 2021 at 15:48)</a>:</h4>
<p>I'm currently working on <a href="https://github.com/rust-lang/rust/issues/78482">#78482</a> and I already have a fix. <br>
However, the <code>for&lt;'a&gt;</code> is highlighted like the <code>&amp;</code>, which wrong, right? How can I "unhighlight" it? </p>
<p><a href="/user_uploads/4715/zmgIIvYOqMBk_vQS8YJBtftD/screen.png">screen.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/zmgIIvYOqMBk_vQS8YJBtftD/screen.png" title="screen.png"><img src="/user_uploads/4715/zmgIIvYOqMBk_vQS8YJBtftD/screen.png"></a></div>



<a name="236978747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/properly%20render%20HRTBs/near/236978747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/properly.20render.20HRTBs.html#236978747">(May 01 2021 at 15:51)</a>:</h4>
<p>Oh, wait. Nvm, I figured it out. <code>primitive_link</code> will format it to be highlighted like this</p>



<a name="237041771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/properly%20render%20HRTBs/near/237041771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/properly.20render.20HRTBs.html#237041771">(May 02 2021 at 09:53)</a>:</h4>
<p>There's one edge case that currently breaks my PR.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">x</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="na">a</span> <span class="kt">u8</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="k">where</span><span class="w"></span>
<span class="w">        </span><span class="n">T</span>: <span class="nc">A</span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>rustdoc will add a <code>for&lt;'a&gt;</code> in front of the bound, which is invalid since <code>'a</code> is already declared.<br>
So I need to remove all lifetimes that are already declared in this scope. </p>
<p>How would I find all lifetimes in the scope of the <code>where</code> bound, to remove them from the list?</p>



<a name="237043617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/properly%20render%20HRTBs/near/237043617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/properly.20render.20HRTBs.html#237043617">(May 02 2021 at 10:29)</a>:</h4>
<p>Mhh, I could get the lifetime parameters of the method, and then try to find the <code>impl</code> or <code>trait</code> where the method is in, and then use these lifetimes <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> </p>
<p>But would that cover all cases?</p>



<a name="237049909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/properly%20render%20HRTBs/near/237049909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/properly.20render.20HRTBs.html#237049909">(May 02 2021 at 12:33)</a>:</h4>
<p>I just noticed that I'm stupid and I can solve this without collecting the lifetimes manually.</p>



<a name="237052396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/properly%20render%20HRTBs/near/237052396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/properly.20render.20HRTBs.html#237052396">(May 02 2021 at 13:20)</a>:</h4>
<p>In general the proper way to do this is a ParamEnv I think</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>